home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / MOVESUB.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  1KB  |  47 lines

  1. ; MOVESUB - move (copy) memory routine for interpretive and compiled BASIC
  2. ; Copyright 1983 Data Base Decisions
  3. ; CALL MOVESUB(FRSEG%,FRLOC%,TOSEG%,TOLOC%,BYTES%)
  4. ; FRSEG% is the segment (DEF SEG) of the source
  5. ; FRLOC% is the location of the source within FROMSEG%
  6. ; TOSEG% is the segment (DEF SEG) of the destination
  7. ; TOLOC% is the location of the destination within TOSEG%
  8. ; BYTES% is the number of bytes to be copied - must be from 1 to 65535
  9.  
  10. ; Note: this routine cannot handle an overlapping copy where the target
  11. ; address is higher than the source address. For example, a copy from
  12. ; 1000:0 to 1000:100 with a length of 200 would copy 1000:0 - 1000:FF
  13. ; correctly, but would duplicate 1000:100 - 1000:1FF, since it would
  14. ; be clobbered by the first part of the copy.
  15.  
  16. cseg    segment para public 'code'
  17. public    movesub
  18. movesub proc far
  19.  
  20.     assume cs:cseg,ds:nothing,ss:nothing,es:nothing
  21.     push bp
  22.     mov bp,sp
  23.     push ds         ; save ds
  24.     push es         ; and es
  25.     mov si,[bp+6]        ; get BYTES%
  26.     mov cx,[si]
  27.     mov si,[bp+8]        ; get TOLOC%
  28.     mov di,[si]
  29.     mov si,[bp+10]        ; get TOSEG%
  30.     mov ax,[si]
  31.     mov es,ax
  32.     mov si,[bp+12]        ; get FRLOC%
  33.     mov bx,[si]        ; hold in bx
  34.     mov si,[bp+14]        ; get FRSEG%
  35.     mov ax,[si]
  36.     mov ds,ax
  37.     mov si,bx        ; all set
  38.     repnz movsb        ; move it
  39.     pop es            ; restore registers
  40.     pop ds
  41.     pop bp            ; return to caller
  42.     ret 10
  43.  
  44. movesub endp
  45. cseg    ends
  46.     end
  47.